

# include "banner.h"

# include <stdio.h>
# include <string.h>
# include <malloc.h>

# include "string_banner.h"

typedef char zchar_8;
typedef int zint_32;

zchar_8* InitString(zchar_8* pCharTest, zint_32 CharSize)
{
	zchar_8* pString;
	pString = (zchar_8*)malloc(sizeof(zchar_8) * CharSize + 1);
	memcpy(pString, pCharTest, CharSize + 1);
	pString[CharSize] = '\0';
	
	return pString;
}

State_banner StringCompare(zchar_8* pFirstString, zchar_8* pSecondString, zint_32 CompareSize)
{
	zint_32 result = 0;
	
	if (pFirstString == NULL || pSecondString == NULL)
		return 0;
		
	if (CompareSize)
	{
		if (*pFirstString == *pSecondString)
		{
			CompareSize--;
			result = StringCompare(pFirstString+1, pSecondString+1, CompareSize);
		}
		else if (*pFirstString > *pSecondString)
			result = 1;
		else
			result = -1;
	}
	
	return result;
}

State_banner DeleteString(zchar_8 **pString)
{
	if (*pString != NULL)
		free(*pString);

	*pString = NULL;

	return 0;
}


